home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / zip.zip / ZIP.H < prev    next >
C/C++ Source or Header  |  1992-09-22  |  8KB  |  249 lines

  1. /*
  2.  
  3.  Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  4.  Permission is granted to any individual or institution to use, copy, or
  5.  redistribute this software so long as all of the original files are included
  6.  unmodified, that it is not sold for profit, and that this copyright notice
  7.  is retained.
  8.  
  9. */
  10.  
  11. /*
  12.  *  zip.h by Mark Adler.
  13.  */
  14.  
  15.  
  16. /* Set up portability */
  17. #include "tailor.h"
  18.  
  19. /* Define malloc() and string functions */
  20. #ifdef MODERN
  21. #  include <string.h>
  22. #else /* !MODERN */
  23.    voidp *malloc();
  24.    char *getenv();
  25.    long atol();
  26.    char *strcpy();
  27.    char *strcat();
  28.    char *strchr();
  29.    char *strrchr();
  30. #  ifndef ZMEM
  31.      char *memset();
  32.      char *memcpy();
  33. #  endif /* !ZMEM */
  34. #endif /* ?MODERN */
  35.  
  36.  
  37. /* Define fseek() commands */
  38. #ifndef SEEK_SET
  39. #  define SEEK_SET 0
  40. #endif /* !SEEK_SET */
  41.  
  42. #ifndef SEEK_CUR
  43. #  define SEEK_CUR 1
  44. #endif /* !SEEK_CUR */
  45.  
  46.  
  47. /* Forget FILENAME_MAX (incorrectly = 14 on some System V) */
  48. #ifdef MSDOS
  49. #  define FNMAX 256
  50. #else /* !MSDOS */
  51. #  define FNMAX 1024
  52. #endif /* ?MSDOS */
  53.  
  54.  
  55. /* Types centralized here for easy modification */
  56. #define local static            /* More meaningful outside functions */
  57. typedef unsigned char uch;      /* unsigned 8-bit value */
  58. typedef unsigned short ush;     /* unsigned 16-bit value */
  59. typedef unsigned long ulg;      /* unsigned 32-bit value */
  60.  
  61.  
  62. /* Lengths of headers after signatures in bytes */
  63. #define LOCHEAD 26
  64. #define CENHEAD 42
  65. #define ENDHEAD 18
  66.  
  67.  
  68. /* Structures for in-memory file information */
  69. struct zlist {
  70.   /* See central header in zipfile.c for what vem..off are */
  71.   ush vem, ver, flg, how;
  72.   ulg tim, crc, siz, len;
  73.   extent nam, ext, cext, com;   /* offset of ext must be >= LOCHEAD */
  74.   ush dsk, att, lflg;           /* offset of lflg must be >= LOCHEAD */
  75.   ulg atx, off;
  76.   char *name;                   /* File name in zip file */
  77.   char *extra;                  /* Extra field (set only if ext != 0) */
  78.   char *cextra;                 /* Extra in central (set only if cext != 0) */
  79.   char *comment;                /* Comment (set only if com != 0) */
  80.   char *zname;                  /* Name for new zip file header */
  81.   int mark;                     /* Marker for files to operate on */
  82.   int trash;                    /* Marker for files to delete */
  83.   struct zlist far *nxt;        /* Pointer to next header in list */
  84. };
  85. struct flist {
  86.   char *name;                   /* Pointer to zero-delimited name */
  87.   char *zname;                  /* Name used for zip file headers */
  88.   struct flist far * far *lst;  /* Pointer to link pointing here */
  89.   struct flist far *nxt;        /* Link to next name */
  90. };
  91.  
  92.  
  93. /* Error return codes and PERR macro */
  94. #include "ziperr.h"
  95.  
  96.  
  97. /* Public globals */
  98. extern char errbuf[];           /* Handy place to build error messages */
  99. extern int recurse;             /* Recurse into directories encountered */
  100. extern int pathput;             /* Store path with name */
  101. #define BEST -1                 /* Use best method */
  102. #define STORE 0                 /* Store method */
  103. #define SHRINK 1                /* Use shrink or store only */
  104. #define IMPLODE 6               /* Use implode or store only */
  105. extern int method;              /* Restriction on compression method */
  106. extern int dosify;              /* Make new entries look like MSDOS */
  107. extern char *special;           /* Don't compress special suffixes */
  108. extern int verbose;             /* Report oddities in zip file structure */
  109. extern int level;               /* Compression level */
  110. #ifdef VMS
  111.    extern int vmsver;           /* Append VMS version number to file names */
  112. #endif /* VMS */
  113. extern int linkput;             /* Store symbolic links as such */
  114. extern int noisy;               /* False for quiet operation */
  115. extern char *key;               /* Scramble password or NULL */
  116. extern char *tempath;           /* Path for temporary files */
  117. extern char *zipfile;           /* New or existing zip archive (zip file) */
  118. extern ulg zipbeg;              /* Starting offset of zip structures */
  119. extern ulg cenbeg;              /* Starting offset of central directory */
  120. extern struct zlist far *zfiles;/* Pointer to list of files in zip file */
  121. extern extent zcount;           /* Number of files in zip file */
  122. extern extent zcomlen;          /* Length of zip file comment */
  123. extern char *zcomment;          /* Zip file comment (not zero-terminated) */
  124. extern struct zlist far **zsort;/* List of files sorted by name */
  125. extern struct flist far *found; /* List of names found */
  126. extern struct flist far * far *fnxt;    /* Where to put next in found list */
  127. extern extent fcount;           /* Count of names in found list */
  128. extern int shract;              /* Shrink active */
  129. extern int impact;              /* Implosion active */
  130.  
  131.  
  132. /* Diagnostic function */
  133. #ifdef DEBUG
  134. #  define diag(where) fprintf(stderr, "zip diagnostic: %s\n", where)
  135. #else /* !DEBUG */
  136. #  define diag(where)
  137. #endif /* ?DEBUG */
  138.  
  139.  
  140. /* Public function prototypes */
  141.  
  142.         /* in zip.c, zipcloak.c, or zipsplit.c */
  143. void warn OF((char *, char *));
  144.  
  145.         /* in zipup.c */
  146. int zipcopy OF((struct zlist far *, FILE *, FILE *));
  147. #ifndef UTIL
  148.    int percent OF((ulg, ulg));
  149.    int zipup OF((struct zlist far *, FILE *));
  150. #endif /* !UTIL */
  151.  
  152.         /* in zipfile.c */
  153. #ifndef UTIL
  154.    struct zlist far *zsearch OF((char *));
  155.    int trash OF((void));
  156. #endif /* !UTIL */
  157. char *ziptyp OF((char *));
  158. int readzipfile OF((void));
  159. int putlocal OF((struct zlist far *, FILE *));
  160. int putcentral OF((struct zlist far *, FILE *));
  161. int putend OF((int, ulg, ulg, extent, char *, FILE *));
  162.  
  163.         /* in fileio.c */
  164. #ifndef UTIL
  165. #  ifdef MSDOS
  166.      int wild OF((char *));
  167. #  endif /* MSDOS */
  168.    char *getnam OF((char *));
  169.    struct flist far *fexpel OF((struct flist far *));
  170.    char *in2ex OF((char *));
  171.    int exclude OF((void));
  172.    int procname OF((char *));
  173.    void stamp OF((char *, ulg));
  174.    ulg dostime OF((int, int, int, int, int, int));
  175.    ulg filetime OF((char *, ulg *, long *));
  176.    int issymlnk OF((ulg a));
  177. #  ifdef S_IFLNK
  178. #    define rdsymlnk(p,b,n) readlink(p,b,n)
  179.      extern int readlink OF((char *, char *, int));
  180. #  else /* !S_IFLNK */
  181. #    define rdsymlnk(p,b,n) (0)
  182. #  endif /* !S_IFLNK */
  183.    int deletedir OF((char *));
  184. #endif /* !UTIL */
  185. int destroy OF((char *));
  186. int replace OF((char *, char *));
  187. int getfileattr OF((char *));
  188. int setfileattr OF((char *, int));
  189. char *tempname OF((int));
  190. int fcopy OF((FILE *, FILE *, ulg));
  191. #ifndef EXPORT
  192. #  ifndef MSVMS
  193.      void echoff OF((int));
  194.      void echon OF((void));
  195. #  endif /* !MSVMS */
  196.    char *getp OF((char *, char *, int));
  197. #endif /* !EXPORT */
  198. #ifdef ZMEM
  199.    char *memset OF((char *, int, unsigned int));
  200.    char *memcpy OF((char *, char *, unsigned int));
  201.    int memcmp OF((char *, char *, unsigned int));
  202. #endif /* ZMEM */
  203.  
  204.         /* in crypt.c */
  205. #ifdef EXPORT
  206. #  define zfwrite fwrite
  207. #else /* !EXPORT */
  208.    void crypthead OF((char *, ulg, FILE *));
  209. #  ifdef UTIL
  210.      int zipcloak OF ((struct zlist far *, FILE *, FILE *, char *));
  211.      int zipbare OF ((struct zlist far *, FILE *, FILE *, char *));
  212. #  else /* !UTIL */
  213.      int zfwrite OF((voidp *, extent, extent, FILE *));
  214.      int zfputc OF((int, FILE *));
  215. #  endif /* ?UTIL */
  216. #endif /* ?EXPORT */
  217.  
  218.         /* in util.c */
  219. char *isshexp OF((char *));
  220. int shmatch OF((char *, char *));
  221. #ifdef MSDOS
  222.    int dosmatch OF((char *, char *));
  223. #endif /* MSDOS */
  224. voidp far **search OF((voidp *, voidp far **, extent,
  225.                        int (*)(voidp *, voidp far *)));
  226. ulg crc32 OF((ulg, int));
  227. ulg updcrc OF((char *, extent));
  228.  
  229.         /* in shrink.c */
  230. #ifndef UTIL
  231.    int shr_setup OF((void));
  232.    int shr_p1 OF((uch *, extent));
  233.    int shr_size OF((ulg *));
  234.    int shr_p2 OF((FILE *));
  235.    int shr_clear OF((void));
  236.   
  237.         /* in implode.c */
  238. #  ifndef NOIMPLODE
  239.      int imp_setup OF((long, int));
  240.      int imp_p1 OF((char *, int));
  241.      int imp_size OF((ulg *, uch *));
  242.      int imp_p2 OF((FILE *));
  243.      int imp_clear OF((void));
  244. #  endif /* !NOIMPLODE */
  245. #endif /* !UTIL */
  246.  
  247.  
  248. /* end of zip.h */
  249.